class PseudoFile:
   def __init__(self):
      """Create a file-like object."""
      pass

   def readline(self):
      pass

   def write(self, s):
      pass

   def writelines(self, l):
      map(self.write, l)

   def flush(self):
      pass

   def isatty(self):
      pass

class PseudoFileIn(PseudoFile):
   def __init__(self, readline, readlines=None):
      if callable(readline):
         self.readline = readline
      else:
         raise ValueError, 'readline must be callable'
      if callable(readlines):
         self.readlines = readlines

   def isatty(self):
      return 1


class PseudoFileOut(PseudoFile):
   def __init__(self, write):
      if callable(write):
         self.write = write
      else:
         raise ValueError, 'write must be callable'

   def isatty(self):
      return 1

class PseudoFileErr(PseudoFile):

    def __init__(self, write):
        if callable(write):
            self.write = write
        else:
            raise ValueError, 'write must be callable'

    def isatty(self):
        return 1
